package com.foomia.truego.parsers.json;

import java.util.Iterator;

import org.json.JSONException;
import org.json.JSONObject;

import com.foomia.truego.types.Geometry;

public class GeometryParser extends AbstractParser<Geometry>{
	@Override
    public Geometry parse(JSONObject json) throws JSONException {
        
		Geometry obj = new Geometry();
		Iterator<String> it = (Iterator<String>)json.keys();
		if (it.hasNext()) {
			String key = (String)it.next();
			JSONObject jso = (JSONObject)json.get(key);
			if (jso.has("lat")) {
	            obj.setLat(jso.getString("lat"));
	        } 
	        if (jso.has("lng")) {
	            obj.setLng(jso.getString("lng"));
	        }
		}
        return obj;
    }

}
